//
//  BaesTableView.m
//  iOSOCProjectDirectory
//
//  Created by apple on 2017/5/26.
//  Copyright © 2017年 XieXuan. All rights reserved.
//

#import "BaesTableView.h"
#import "NoContenView.h"

@interface BaesTableView (){
    NoContenView *_noContentView;
}

@end

@implementation BaesTableView


-(void)showPlaceholderViewWithImageName:(NSString *)imageName text:(NSString *)text{
    // 如果已经展示无数据占位图，先移除
    if (_noContentView) {
        [_noContentView removeFromSuperview];
        _noContentView = nil;
    }
    
    //------- 再创建 -------//
    _noContentView = [[NoContenView alloc]initWithFrame:self.bounds];
    [self addSubview:_noContentView];
    [_noContentView setImage:imageName topLabelText:text];
    
    //------- 添加单击手势 -------//
    [_noContentView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noContentViewDidTaped:)]];

}

// 无数据占位图点击
- (void)noContentViewDidTaped:(NoContenView *)noContentView{
    if (self.noContentViewTapedBlock)
    {
        self.noContentViewTapedBlock();//调用回调函数
    }
}
-(void)hidePlaceholderView{
    [_noContentView removeFromSuperview];
    _noContentView = nil;
}

@end
